package com.gz.droolsrule.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gz.droolsrule.dao.BaseRuleConditionInfoMapper;
import com.gz.droolsrule.pojo.BaseRuleConditionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: RuleConditionService <br/>
 * Description: <br/>
 * date: 2019/5/31 16:00<br/>
 *
 * @author gz<br />
 * @since JDK 1.8
 */
@Service
public class RuleConditionService {
    @Autowired
    private BaseRuleConditionInfoMapper baseRuleConditionInfoMapper;

    /**
     * 方法说明: 根据规则获取规则条件信息
     *
     * @param baseRuleConditionInfo 参数
     * @param page                  分页参数
     */
    public PageInfo<BaseRuleConditionInfo> findBaseRuleConditionInfoPage(BaseRuleConditionInfo baseRuleConditionInfo, PageInfo page) {

        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<BaseRuleConditionInfo> list = this.baseRuleConditionInfoMapper.findBaseRuleConditionInfoList(baseRuleConditionInfo);
        return PageInfo.of(list);
    }

    /**
     * 方法说明: 根据规则id获取规则条件信息
     *
     * @param ruleId 规则id
     */
    public List<BaseRuleConditionInfo> findRuleConditionInfoByRuleId(Long ruleId) {
        if (null == ruleId) {
            return null;
        }
        return this.baseRuleConditionInfoMapper.findRuleConditionInfoByRuleId(ruleId, null);
    }
}
